//
//  HEFlowVideoCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/12/18.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HEFlowVideoCell.h"
#import "UIView+MZwebCache.h"

@interface HEFlowVideoCell ()


@property (nonatomic, strong) UIImageView *coverView;
@property (nonatomic, strong) UILabel *descLb;

@end

@implementation HEFlowVideoCell

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self initUI];
    }
    return self;
}

- (void)initUI {
    _coverView = [UIImageView new];
    _coverView.contentMode = UIViewContentModeScaleAspectFill;
    [self.contentView addSubview:_coverView];
    _coverView.clipsToBounds = YES;
    _coverView.layer.masksToBounds = YES;
    _coverView.layer.cornerRadius = 6;
    
    _descLb = [UILabel new];
    _descLb.text = @"骨质疏松，严重容易死质疏松，严重容易死亡";
    _descLb.font = DYFont(15);
    _descLb.numberOfLines = 1;
    _descLb.textColor = CNavLightBlackColor;
    [self.contentView addSubview:_descLb];
    
    [_coverView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(0);
        make.left.equalTo(self.contentView).offset(0);
        make.right.equalTo(self.contentView).offset(-0);
    }];
    
    [_descLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_coverView.mas_bottom).offset(10);
        make.left.equalTo(self.contentView).offset(0);
        make.right.equalTo(self.contentView).offset(-0);
        make.bottom.equalTo(self.contentView).offset(-0);
    }];
    
    [_descLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];

}

- (void)setModel:(HEVideoListModel *)model {
    KWeakSelf
//    [_coverView sd_setImageWithURL:[NSURL URLWithString:model.video_icon] placeholderImage:IMAGE_NAMED(@"noImage") completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
//
//        if (!error && image) {
//            if (model.imageSize.width < 0.0001) {
//                model.imageSize = image.size;
//                if (weakSelf.sizeChanged) {
//                    weakSelf.sizeChanged();
//                }
//            }
//        }
//    }];
    
//    [_coverView setImageWithUrl:[NSURL URLWithString:model.video_icon] placeHolder:[UIImage imageNamed:@"noImage"] completion:^(UIImage *image, BOOL bFromCache, NSError *error) {
//        if (!error && image) {
//            if (model.imageSize.width < 0.0001) {
//                model.imageSize = image.size;
//                if (weakSelf.sizeChanged) {
//                    weakSelf.sizeChanged();
//                }
//            }
//        }
//    }];
    _descLb.text = model.title;
     
//    [_coverView mas_updateConstraints:^(MASConstraintMaker *make) {
//        make.height.offset(model.imageSize.height);
//    }];
}

@end
